{layout name="layout" /}
<div class="row m-t-xs  p-t-5 text-center" id='content_replace'>
    <div class="col-xs-12 p-t-lg p-b-lg " style='height:20%'>
        <div class="container p-t-lg p-b-lg">
            <h2>{$member_info.username|default='暂无'}</h2>
        </div>
    </div>
    <div class="list-group" style="font-size: 1.6rem">
        <button type="button" class="list-group-item p-t-sm p-b-sm show_info_form_div">
            <span class="glyphicon glyphicon-edit p-l-sm p-r-sm"></span>修改信息
        </button>
        <button type="button" class="list-group-item p-t-sm p-b-sm show_password_form_div">
            <span class="glyphicon glyphicon-exclamation-sign p-l-sm p-r-sm"></span>修改密码
        </button>
        <button type="button" class="list-group-item p-t-sm p-b-sm" onclick="location.href='{:merge_url('member/login');}'">
            <span class="glyphicon glyphicon-log-out p-l-sm p-r-sm"></span>注销登陆
        </button>
    </div>
    <div class="col-xs-12 hide" id='hide_info_form_div'>
        <form class="form-horizontal info_form"  action="{:url('');}"  method="post">
            <div class="form-group row">
                <label for="date" class="col-xs-2 control-label p-t-xs p-b-xs  p-l-md" style="text-align:left">用户名</label>
                <div class="col-xs-9 m-l-sm">
                    <input name="username" type="text" class="form-control" id="username_input" placeholder="" value="{$member_info.username|default=''}">
                </div>
            </div>
        </form>
    </div>
    <div class="col-xs-12 hide" id='hide_password_form_div'>
        <form class="form-horizontal password_form"  action="{:url('');}"  method="post">
            <div class="form-group row">
                <label for="date" class="col-xs-2 control-label p-t-xs p-b-xs  p-l-md" style="text-align:left">原密码</label>
                <div class="col-xs-9 m-l-sm">
                    <input name="old_password" type="password" class="form-control" id="old_password_input" placeholder="" value="">
                </div>
            </div>
            <div class="form-group row">
                <label for="date" class="col-xs-2 control-label p-t-xs p-b-xs  p-l-md" style="text-align:left">新密码</label>
                <div class="col-xs-9 m-l-sm">
                    <input name="password" type="password" class="form-control" id="password_input" placeholder="" value="">
                </div>
            </div>
        </form>
    </div>
</div>
<script>
    $(function($){
        $(".show_info_form_div").on('click',function()
        {
                    var hide_form_div = $('#hide_info_form_div').first();
                    layer.open({
                            content:hide_form_div.html(),
                            btn: '提交',
                            style: 'position:relative;top:-30px',
                            success : function(){
                                    
                            },
                            yes: function(){
                                      hide_info_form = $('.layui-m-layer .info_form');
                                      console.log(hide_info_form.serializeArray());
                                      $.post('{:merge_url('',['change_info'=>1]);}',hide_info_form.serializeArray(),function(res) {
                                                if(res.code==1){
                                                        layer_tips("修改成功",  function()
                                                        {
                                                           layer.closeAll();
                                                           ajax_load('{:merge_url('');}');
                                                        });
                                                }else{
                                                        layer_tips(res.msg,  function()
                                                        {
                                                           layer.closeAll();
                                                        });
                                                }
                                      });
                                      
                            }
                    });
        });
        $(".show_password_form_div").on('click',function()
        {
                    var hide_form_div = $('#hide_password_form_div').first();
                    layer.open({
                            content:hide_form_div.html(),
                            btn: '提交',
                            style: 'position:relative;top:-30px',
                            success : function(){
                                    
                            },
                            yes: function(){
                                      hide_password_form = $('.layui-m-layer .password_form');
                                      console.log(hide_password_form.serializeArray());
                                      $.post('{:merge_url('',['change_password'=>1]);}',hide_password_form.serializeArray(),function(res) {
                                                if(res.code==1){
                                                    layer_tips("修改成功",  function()
                                                    {
                                                        layer.closeAll();
                                                        location.href = '{:merge_url('login');}';
                                                    });
                                                }else{
                                                        layer_tips(res.msg,  function()
                                                        {
                                                           layer.closeAll();
                                                        });
                                                 }        
                                      });
                                      
                            }
                    });
        });
    });
</script>